<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>add</title>
    <script>
        function add() {
            var arr = new Array();
            var ids = document.getElementsByName('ches');
            for (var i = 0; i < ids.length; i++) {
                if (ids[i].checked) {
                    arr.push(ids[i].value);
                }
            }
            document.getElementById('str').value = arr.join(',');
        }
    </script>
</head>
<body>
<form action="/add" method="post">
    <table align="center" border="1px" cellpadding="0px" cellspacing="0px" width="20%">
        <tr align="center">
            <th>姓名</th>
            <td><input type="text" name="name"></td>
        </tr>
        <tr align="center">
            <th>日期</th>
            <td><input type="date" name="date"></td>
        </tr>
        <tr align="center">
            <th>是否上门</th>
            <td>
                <select name="shangmen">
                    <option value="是">是</option>
                    <option value="否">否</option>
                </select>
            </td>
        </tr>
        <tr align="center">
            <th>来源</th>
            <td><input type="text" name="laiyuan"></td>
        </tr>
        <tr align="center">
            <th>年级</th>
            <td>
                <select name="nianji">
                    <#list list as n>
                        <option value="${n.id}">${n.nianji}</option>
                    </#list>
                </select>
            </td>
        </tr>
        <tr align="center">
            <td colspan="2"><input type="submit" onclick="add()" value="添加"></td>
        </tr>
    </table>
    <input type="checkbox" name="ches" checked value="1">1
    <input type="checkbox" name="ches" value="2">2
    <input type="checkbox" name="ches" checked value="3">3
    <input type="checkbox" name="ches" value="4">4
    <input type="hidden" name="ids" id="str">
</form>
</body>
</html>